import type { FunctionalComponent, defineComponent } from 'vue';
import type { ComponentType } from '../../types/componentType';
import { componentMap } from '@/components/Table/src/componentMap';

import { h } from 'vue';

export interface ComponentProps {
  component: ComponentType;
  rule: boolean;
  popoverVisible: boolean;
  ruleMessage: string;
}

export const CellComponent: FunctionalComponent = (
  { component = 'Input' }: ComponentProps,
  { attrs },
) => {
  const Comp = componentMap.get(component) as typeof defineComponent;
  const DefaultComp = h(Comp, attrs);
  return DefaultComp;
  // if (!rule) {
  //   return DefaultComp;
  // }
  // return h(
  //   Popconfirm,
  //   {
  //     contentClass: 'edit-cell-rule-popover',
  //     popupVisible: !!popoverVisible,
  //   },
  //   {
  //     default: () => DefaultComp,
  //     content: () => ruleMessage,
  //   },
  // );
};
